'use strict';
/* Controllers */
app.controller('teamCtrl', ['$scope', 'apiService', '$rootScope', 'toaster', function ($scope, apiService, $rootScope, toaster) {

    // 获取会员
    $scope.getUserList = function (find_obj, show_type) {
        if (find_obj['id']) {
            find_obj['previous'] = find_obj['id'];
        }
        apiService.post({
            modelName: 'member',
            apiName: 'getmemberdbDiyiDai'
        }, find_obj, function (data) {
            if (data.code == 200) {
                if (show_type == 1) {
                    $scope.oneList = data['data'];
                } else if (show_type == 2) {
                    $scope.threeList=[];
                    $scope.twoList = data['data'];
                } else if (show_type == 3) {
                    $scope.threeList = data['data'];
                }
            } else {
                toaster.pop('error', '提示', data['msc']);
            }
        }, function (err) {
            toaster.pop('error', '提示', '服务器出小差咯...');
        });
    };

    // 初始化
    var find_obj = {
        previous: $rootScope.userObj['id']
    };
    $scope.getUserList(find_obj, 1);


    $scope.getInfo = function (items,userInfo) {
        angular.forEach(items, function (item) {
            item.selected = false;
        });
        userInfo.selected=true;
        $scope.userInfo = userInfo;
    }

}]);